package com.mediacloud.app.newsmodule.fragment.audio.vod;


import com.mediacloud.app.newsmodule.adaptor.NewsListItemStyleAdaptor;
import com.mediacloud.app.newsmodule.adaptor.audio.vod.AudioVodNewsListItemStyleAdaptor;
import com.mediacloud.app.newsmodule.adaptor.bigimg_nosliceline.BigImageNoSliceLineAdaptor;
import com.mediacloud.app.newsmodule.fragment.newslist.NewsListWidthBannerFragment;
import com.mediacloud.app.reslib.enums.StyleOther;

/**
 * 音频点播列表的新闻
 */
public class AudioVodNewsListFragment extends NewsListWidthBannerFragment {

    public AudioVodNewsListFragment() {
    }

    @Override
    public void initView() {
        super.initView();
//		if(adaptor==null)
//		{

//		}
    }

    @Override
    public void beforeUserCache() {
        super.beforeUserCache();
        if (adaptor instanceof BigImageNoSliceLineAdaptor) {
            ((BigImageNoSliceLineAdaptor) adaptor).destroy();
        }
        if (adaptor instanceof NewsListItemStyleAdaptor) {
            ((NewsListItemStyleAdaptor) adaptor).destroy();
        }
        //如果有其他样式的 就用这个列表样式了
        if (catalogItem.getCatalogStyle() == StyleOther.OtherStyle)//&&catalogItem.getStyleOther()!=null)
        {
            adaptor = new BigImageNoSliceLineAdaptor(getActivity(), catalogItem, null);
        } else {
            adaptor = new AudioVodNewsListItemStyleAdaptor(getActivity(), catalogItem);
        }
        mCatalogContentItemListView.setAdapter(adaptor);
    }

    @Override
    protected void addBanner() {
        int extraStyle = catalogItem != null ? catalogItem.getCatalogStyle() : 0;
        if (extraStyle > 0)
            haveBanner = false;
        else
            super.addBanner();
    }

    @Override
    public void onDestroyView() {
        if (adaptor instanceof AudioVodNewsListItemStyleAdaptor) {
            ((AudioVodNewsListItemStyleAdaptor) adaptor).clearEvent();
            ((AudioVodNewsListItemStyleAdaptor) adaptor).clearSpiderObservers();
        }
        super.onDestroyView();
    }
}